﻿// -----------------------------------------------------------------------
// <copyright file="MainForm.cs" company="FCIS">
// You are welcome to do whatever you want with the code in this file
// </copyright>
// -----------------------------------------------------------------------

namespace ImagePackage.WindowsForms
{
    using System.ComponentModel;
    using System.Windows.Forms;

    /// <summary>
    /// The Main form 
    /// </summary>
    public partial class MainForm : Form
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="MainForm"/> class.
        /// </summary>
        public MainForm()
        {
            this.InitializeComponent();
        }

        #region Event Handlers

        /// <summary>
        /// Handles the Click event of the openToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void OpenToolStripMenuItemClick(object sender, System.EventArgs e)
        {
            this.Open();
        }

        /// <summary>
        /// Handles the Click event of the exitToolStripMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void ExitToolStripMenuItemClick(object sender, System.EventArgs e)
        {
            this.Exit();
        }

        #endregion

        #region Commands

        /// <summary>
        /// Opens this instance.
        /// </summary>
        private void Open()
        {
            if (this.ofdMain.ShowDialog() == DialogResult.OK)
            {
                IO.InOutService inOutService = new IO.InOutService();

                Model.Image current = inOutService.Open(this.ofdMain.FileName);

                ImageContainerForm container = new ImageContainerForm(current) { MdiParent = this };
                
                container.Show();
            }
        }

        /// <summary>
        /// Exits this instance.
        /// </summary>
        private void Exit()
        {
            Application.Exit();
        }

        #endregion
    }
}